package main

import (
	"image/color"
	"machine"

	"tinygo.org/x/drivers/ssd1306"
	"tinygo.org/x/tinyfont"
	"tinygo.org/x/tinyfont/freesans"
)

func main() {
	machine.I2C0.Configure(machine.I2CConfig{
		Frequency: machine.TWI_FREQ_400KHZ,
		SDA:       machine.Pin(4),
		SCL:       machine.Pin(5),
	})

	display := ssd1306.NewI2C(machine.I2C0)
	display.Configure(ssd1306.Config{
		Address: ssd1306.Address_128_32,
		Width:   128,
		Height:  64,
	})

	display.ClearDisplay()

	display.ClearBuffer()
	display.ClearDisplay()

	c := color.RGBA{0xff, 0xff, 0xff, 0xff}
	tinyfont.WriteLine(&display, &freesans.Regular12pt7b, 20, 40, "TinyGo", c)
	display.Display()
}
